<template>
	<view class="score_box">
		<view class="now">
			<view>{{score}}</view>
			<view class="now_score">当前积分</view>
		</view>
		<view>积分收支记录</view>
		<view class="det" v-for="(v,i) in list">
			<view>{{v.type}}</view>
			<view>{{v.number}}</view>
		</view>
	</view>
</template>

<script>
	import http from '@/utils/http.js'
	export default {
		data() {
			return {
				phone:'',
				status:'',
				userid:'',
				score:'',
				list:[
					{
						id:'',
						type:'',
						number:'',
						user_ID:''
					}
				]
			}
		},
		onShow() {
			this.phone=uni.getStorageSync('phone');
			this.status=uni.getStorageSync('status');
			this.getUID();
			this.userid=uni.getStorageSync('userid',this.userid);
			console.log("userid_score:",this.userid)
			this.getscore()
		},
		methods: {
			getUID(){
				http({
					method:'post',
					url:'/getUID',
					data:{
						phone:this.phone
					},
					success:(res)=>{
						this.userid=res.data.data[0].id
						this.score=res.data.data[0].score
						 if(res.data.msg=='请先登录'){
							uni.navigateTo({
								url:'/pages/login/login',
							})
						}
					}
				})
				// if(!this.userid){
				// 	uni.navigateTo({
				// 		url:'/pages/login/login',
				// 	})
				// }				
			},
			getscore(){
				http({
					method:'post',
					url:'/getscore',
					data:{
						userid:this.userid
					},
					success:(res)=>{
						if(res.data){
							this.list=res.data.data
						}
						else if(res.msg=='还没有积分'){
							// alert('还没有积分')
							
						}
					}
				})
				
			},
		}
	}
</script>

<style>
.score_box{
	background-color: rgba(245, 247, 247, 1);
	width: 375px;
	height: 750px;
}
.now{
	width: 90%;
	height: 200rpx;
	margin-left: 5%;
	margin-top: 20rpx;
	background-color: white;
	border-radius: 12rpx;
}
.now view:nth-child(1){
	height: 80rpx;
	font-size: 56rpx;
	text-align: center;
	line-height: 72rpx;
	margin-top: 20rpx;
	color: #333;
}
.now view:nth-child(2){
	font-size: 28rpx;
  height: 80rpx;
	line-height: 72rpx;
  color: #999;
  padding-left: 240rpx;
}
.score_box view:nth-child(2){	
	color: #333333;
  width: 85px;
	height: 20px;
	font-size: 28rpx;
	margin: 30rpx;
}
.det{
	width: 100%;
	height: 100rpx;
	margin-top: 30rpx;
	border-bottom: #CCCCCC solid 1rpx;
	background-color: white;
	position: relative;
}
.det view:nth-child(1){
	font-size: 28rpx;
	color: #333;
	margin-left: 30rpx;
	display: inline-block;
    line-height: 46rpx;
    position: absolute;
    left: 10px;
    top: 25rpx;
}
.det view:nth-child(2){
	font-size: 28rpx;
	color: #F77214;
  display: inline-block;
  line-height: 46rpx;
  position: absolute; 
  right: -80rpx;
}
</style>
